<template>
  <div>
    <template v-if="disabled">
      {{ data[secretLevelKey] | mijiCodeFilter }}
    </template>
    <m-select v-else :value.sync="data[secretLevelKey]" :option="options" value-key="codeValue" @change="handleChange" />
  </div>
</template>

<script>
export default {
  name: 'MSecretLevel',
  props: {
    disabled: {
      type: Boolean,
      default: false,
    },
    data: {
      type: Object,
      default: () => {
        return {
          dataLevel: '',
        }
      },
    },
    secretLevelKey: {
      type: String,
      default: 'dataLevel',
    },
    fileKeyList: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {
      options: this.$state['user-level-options'],
    }
  },
  methods: {
    handleChange() {
      this.fileKeyList.forEach(key => {
        this.data[key] = []
      })
    },
  },
}
</script>
